package string.leetcode.easy;

/**
 * @author bruin_du
 * @description 替换空格
 * @date 2022/5/10 18:35
 **/
public class offer05_ReplaceSpace {
    public String replaceSpace(String s) {
        if(s == null || s.length() == 0)
            return s;
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < s.length(); i++) {
            char ch = s.charAt(i);
            if(ch != ' ')
                sb.append(ch);
            else
                sb.append("%20");
        }
        return sb.toString();
    }
}
